import { _decorator, Component, Node, Sprite, SpriteFrame } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Block')
export class Block extends Component {

    /**
     * 1-蓝色  2-红色  3-黄色  4-绿色(数值对应座位号)
     * 下标数值-1
     * 灰色放在末尾
     */
    @property([SpriteFrame])
    blockSkins: SpriteFrame[] = [];

    protected onLoad(): void {

    }

    start() {

    }

    public initBlock(isShow: boolean) {
        this.node.active = isShow;
    }

    public setBlock(seatId: number, isShow: boolean) {
        this.node.active = isShow;
        if (!isShow) return;
        let frame: SpriteFrame = null;
        if (seatId > 0 && seatId < 5) {
            frame = this.blockSkins[seatId - 1];
        } else {
            /** 灰色单独处理 */
            frame = this.blockSkins[4];
        }
        this.node.getComponent(Sprite).spriteFrame = frame;
    }

    update(deltaTime: number) {

    }
}


